<template>
  <div>
    <!-- //面包屑/ -->


    <!-- //搜索 -->
    <el-from :inline="true">
      <el-input
        placeholder="请输入内容"
        v-model="input3"
        class="input-with-select"
      >
        <el-button slot="append" icon="el-icon-search"></el-button>
      </el-input>
      <el-button type="primary" class="add" @click="add">添加</el-button>
    </el-from>
    <!-- //表格 -->
    <bgs :goods="goods" @delet="del" :buffn="buffn" @Edits="Editmenu"></bgs>
    <mtks ref="formMenu" :buffn="buffn" :good="goods"></mtks>
  </div>
</template>
<script>
import bgs from "./components/bg.vue";
import mtks from "./components/mtk.vue";
export default {
  components: {
    bgs,
    mtks,
  },
  data() {
    return {
      input3: "",
      goods: [],
      buffn: {
        off: false,
      },
    };
  },
  created() {
    this.$api
      .reqgoods({ istree: true })
      .then((res) => {
        // console.log(res.data.list);
        this.goods = res.data.list;
        this.buffn.off = false;
      })
      .catch((err) => console.log(err));
  },
  methods: {
    //打开模态框
    add() {
      // console.log(1);
      this.buffn.off = true;
    },
    //删除
    del(id) {
      console.log(id);
      this.$api.reqDele({ id: id }).then((res) => {
        // console.log(res);
        this.$message({
          showClose: true,
          message: "删除成功",
          type: "success",
        });
        this.$router.go(0)
      });
    },
    //编辑
    Editmenu(row) {
      // let { index, row } = info;
      delete row.children;
      this.$refs.formMenu.form = JSON.parse(JSON.stringify(row));
      this.buffn.off = true;
    },
  },
};
</script>
<style lang="scss" scoped>
.input-with-select {
  width: 700px;
}
.add {
  margin-left: 200px;
}

.input-with-select {
  padding: 20px 0;
}
.input-with-select {
  width: 600px;
}
</style>